﻿/*
 * 作者：蒲森
 * 功能描述：套管柱结构
 * 时间：2018-01-17
 * 修改人：
 * 修改时间：
 *
 */
using DataAccess;
using Entity;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataBusiness
{
    public class CasingStringBLL
    {
       
        /// <summary>
        /// 删除数据
        /// </summary>
        /// <param name="CasingStringId"></param>
        /// <returns></returns>
        public static int DeleteCasingString(string CasingStringId)
        {
            string sSql = string.Format(("delete from tb_CasingString where ID= '{0}'"), CasingStringId);
            return SqlHelper.ExeSql(sSql);
        }

        /// <summary>
        /// 修改数据
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        public static int UpdateCasingString(tb_CasingStringModel t)
        {
            //第一种方式
            string sSql = string.Format("update tb_CasingString set WellNo = '{1}',CasingProgram = '{2}',StartLocation = '{3}',EndLocation = '{4}',StandardSize = '{5}',ConnectionType = '{6}',CasingLength = '{7}',CasingGrade = '{8}',WallThickness = '{9}',WeightPerMeter = '{10}',CasingWeight = '{11}',"
                + "ExtrusionStrength = '{12}',ExtrusionSafetyFactor = '{13}',BurstStrength = '{14}',BurstSafetyFactor = '{15}',TensileStrength = '{16}',TensileSafetyFactor = '{17}',TriAxialSafetyFactor = '{18}',UserID = '{19}',InputDate = '{20}' where ID = '{0}'"
                , Convert.ToDecimal(t.ID), t.WellNo, t.CasingProgram, Convert.ToDecimal(t.StartLocation), Convert.ToDecimal(t.EndLocation), Convert.ToDecimal(t.StandardSize), t.ConnectionType, Convert.ToDecimal(t.CasingLength), t.CasingGrade, Convert.ToDecimal(t.WallThickness), Convert.ToDecimal(t.WeightPerMeter), Convert.ToDecimal(t.CasingWeight), Convert.ToDecimal(t.ExtrusionStrength), Convert.ToDecimal(t.ExtrusionSafetyFactor), Convert.ToDecimal(t.BurstStrength),
                Convert.ToDecimal(t.BurstSafetyFactor), Convert.ToDecimal(t.TensileStrength), Convert.ToDecimal(t.TensileSafetyFactor),
                Convert.ToDecimal(t.TriAxialSafetyFactor), t.UserID, t.InputDate);
            return SqlHelper.ExeSql(sSql);
        }

        /// <summary>
        /// 插入数据
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        public static int InsertCasingString(tb_CasingStringModel t)
        {
            //第一种方式 拼接sql语句字符串
            
            string sSql = string.Format("Insert into tb_CasingString(WellNo,CasingProgram,StartLocation,EndLocation,StandardSize,ConnectionType,CasingLength,CasingGrade,WallThickness,WeightPerMeter,CasingWeight,"
                + "ExtrusionStrength,ExtrusionSafetyFactor,BurstStrength,BurstSafetyFactor,TensileStrength,TensileSafetyFactor,TriAxialSafetyFactor,UserID,InputDate) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}')"
                , t.WellNo, t.CasingProgram, Convert.ToDecimal(t.StartLocation), Convert.ToDecimal( t.EndLocation), Convert.ToDecimal(t.StandardSize), t.ConnectionType, Convert.ToDecimal(t.CasingLength), t.CasingGrade, Convert.ToDecimal(t.WallThickness), Convert.ToDecimal(t.WeightPerMeter), Convert.ToDecimal(t.CasingWeight), Convert.ToDecimal(t.ExtrusionStrength), Convert.ToDecimal(t.ExtrusionSafetyFactor), Convert.ToDecimal(t.BurstStrength), 
                Convert.ToDecimal(t.BurstSafetyFactor), Convert.ToDecimal(t.TensileStrength), Convert.ToDecimal(t.TensileSafetyFactor),
                Convert.ToDecimal(t.TriAxialSafetyFactor), t.UserID, t.InputDate);
            return SqlHelper.ExeSql(sSql);
        }

        /// <summary>
        /// 将well表中的wellno添加至一个集合
        /// </summary>
        /// <returns></returns>
        public static List<string> SelectWellNo()
        {
            List<string> list = new List<string>();
            string sql = "select WellNo  from tb_Well";
            DataTable dt = SqlHelper.QuerySqlByDataTable(sql);
            foreach (DataRow row in dt.Rows)
            {
                list.Add(row["WellNo"].ToString());
            }
            return list;
        }
    }
}

